﻿Namespace Localization
    <System.Windows.Markup.MarkupExtensionReturnType(GetType(System.Windows.Markup.XmlLanguage))> _
    Public Class LanguageExtension
        Inherits System.Windows.Markup.MarkupExtension

        Private Shared _Language As System.Windows.Markup.XmlLanguage
        Public Overrides Function ProvideValue(ByVal serviceProvider As System.IServiceProvider) As Object
            If _Language Is Nothing OrElse System.Globalization.CultureInfo.CurrentUICulture.IetfLanguageTag <> _Language.IetfLanguageTag Then
                _Language = System.Windows.Markup.XmlLanguage.GetLanguage(System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag)
            End If
            Return _Language
        End Function
    End Class

End Namespace
